package com.ruoyi.system.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.product.ProductCategoryDO;
import com.ruoyi.common.entity.DO.product.ProductDO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


import java.util.List;


/**
 * 商品分类 数据层
 *
 * @author lijiantao
 */
public interface IAsyncProductCategoryMapper extends BaseMapper<ProductCategoryDO> {

    @Select("SELECT pc.product_id id,GROUP_CONCAT(category_name) productCategory FROM product_category c" +
            " LEFT JOIN product_category_link pc ON c.id = pc.category_id" +
            " WHERE pc.product_id IN (SELECT product_id FROM product_category_link WHERE category_id =#{categoryId})" +
            " GROUP BY product_id")
    List<ProductDO> listProductLinkCategoryId(@Param("categoryId") Long categoryId);

}
